﻿Imports CustomTshirtFinal

Public Class UsuarioEditar
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then

            Dim id = Request.Params.Get("id")

            Dim negocio = New UsuarioNegocio
            Dim modelo = negocio.obtener(id)

            Me.txtIdUsuario.Value = modelo.idUsuario
            Me.txtNombre.Text = modelo.nombre
            Me.txtApellido.Text = modelo.apellido
            Me.txtTelefono.Text = modelo.telefono
            Me.txtCorreo.Text = modelo.correo
            Me.txtSexo.Text = modelo.sexo
            Me.txtPassword.Text = modelo.pass

        End If
    End Sub

    Protected Sub btnGuardar_Click(sender As Object, e As EventArgs) Handles btnGuardar.Click
        Try
            Dim negocio = New UsuarioNegocio
            negocio.actualizar(Me.txtIdUsuario.Value, Me.txtNombre.Text, Me.txtApellido.Text, Me.txtTelefono.Text, Me.txtCorreo.Text, Me.txtSexo.Text, Me.txtPassword.Text)

            Response.Redirect("Usuarios.aspx", True)
        Catch ex As Exception
            Response.Write("No se pudo actualizar")
        End Try
    End Sub

    Protected Sub btnRegresar_Click(sender As Object, e As EventArgs) Handles btnRegresar.Click
        Response.Redirect("Usuarios.aspx", True)
    End Sub

   
End Class